import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const request = axios.create({
  baseURL: '/mock',
  timeout: 200000
})

//请求拦截器
request.interceptors.request.use((config)=> {

  NProgress.start()

  return config
},(err) => {
  NProgress.done()
  console.error(err);
  return Promise.reject(err)
}
)

//响应拦截器
request.interceptors.response.use((response) => {

  NProgress.done()

  // console.log(response);

  return response.data
},(err) => {
  NProgress.done()
  console.error(err);
  return Promise.reject(err)
})

export default request;